< previous page page_581 next page >

Page 581
Phong Shading
Phong shading also uses vertex normals to create smooth shading. Gouraud shading uses the vertex normals to compute vertex colors. It then interpolates using those colors to find the colors of the points inside a polygon. Phong shading interpolates using the vertex normals to find normals for each point in a polygon. It then uses those normals to compute the points' colors individually.
The most time-consuming part of both methods is computing the color of a point given its surface nromal. Interpolating colors or normal vectors is relatively fast. Because gouraud shading computes only the colors of the vertices and Phong shading computes the color of each point individually, Phong shading takes longer.
On the other hand, Phong shading generally produces a beter result. Interpolating normals instead of colors means the change in color varies more evenly, so the edges between ploygons are less noticeable.
Phong shading calculates colors for every point based on a smoothly varying normal vector. For some points, the vector is likely to point in the mirror direction for the viewing position. Those points have significant specular reflection terms, so the surface has highlights.
Example program Phong, shown in Figures 16.16 and 16.17, draws a sphere with Phong shading. Compare Figure 16.16 with Figures 16.13 and 16.14. Phong shading produces an excellent result for the interior of the sphere, though the edges are still lumpy. It produces a much better result than the sphere with Gouraud shading shown in Figure 16.13.
0581-01.jpg
Figure 16.16
Phong shading of a sphere containing 100 polygons.

 
< previous page page_581 next page >